function dateFormat(dateStr) {
    const d = new Date(dateStr);

    //年月日
    const year = d.getFullYear();
    const month = padZero(d.getMonth() + 1);
    const date = padZero(d.getDate());

    //时分秒
    const hours = padZero(d.getHours());
    const minutes = padZero(d.getMinutes());
    const seconds = padZero(d.getSeconds());

    return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`
}

// ? 定义补0函数
function padZero(n) {
    return n > 9 ? n : '0' + n
}

module.exports = {
    dateFormat
}